{%- extends 'index.html' -%}
{%- block body -%}
	<div class="post">
		<div class="row">
			<div class="col-lg-12">
				{%- if posts -%}
					<div class="page-header">
						<h1>Posts</h1>
					</div>
					<div class="content">
						{%- with messages = get_flashed_messages(with_categories=True) -%}
		                    {%- if messages -%}
		                        {%- for category, message in messages -%}
		                            <div class="response">
		                                <span class="message {{ category }}">{%- if category == 'success' -%}✔{%- endif -%}&nbsp;{{ message }}</span>
		                            </div>
		                        {%- endfor -%}
		                    {%- endif -%}
		                {%- endwith -%}
						<a href="{{ url_for('new_post') }}" class="response btn btn-primary">Add new</a>
						<table class="table table-striped">
							<tr>
								<th>Title</th>
								<th>Post Date</th>
								<th>Action</th>
							</tr>
							{%- for post in posts -%}
							<tr>
								<td><a title="Preview" href="{{ url_for('single_post', permalink=post['permalink']) }}" data-target="_blank">{{ post['title'] | safe }}</a></td>
								<td>{{ post['date'] |formatdate }}</td>
								<td><a title="Edit" href="{{ url_for('post_edit', id=post['id']) }}" class="icon-edit-sign bigger icon"></a>{%- if posts|length > 1 -%}&nbsp;&nbsp;<a title="Delete" href="{{ url_for('post_del', id=post['id']) }}" class="icon-remove-sign bigger icon"></a>{%- endif -%}</td>
							</tr>
							{%- endfor -%}
						</table>
					</div>
				{%- else -%}
					<div class="page-header">
						<h1>Posts not found..</h1>
					</div>
				{%- endif -%}
		    </div>
		</div>
	</div>
{%- endblock -%}
